from appium import webdriver
from appium.webdriver.common.appiumby import By
from time import sleep
from appium.webdriver.common.touch_action import TouchAction
from zoom import *

desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '7'
desired_caps['deviceName'] = '127.0.0.1:62001'
desired_caps['app'] = r'D:\apk\autonavi.apk'
desired_caps['appPackage'] = r'com.autonavi.minimap'
desired_caps['appActivity'] = r'com.autonavi.map.activity.SplashActivity'
desired_caps['noReset'] = False  # False代表重置（重新安装），默认值就是False

dr = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
dr.implicitly_wait(10)  # 隐式等待
sleep(1)


# 点击同意
dr.find_element(By.ID, 'com.autonavi.minimap:id/agree').click()
sleep(1)
# 跳过
dr.find_element(By.ID, 'com.autonavi.minimap:id/skip_btn').click()
sleep(1)
# 点击允许
dr.find_element(By.ID, 'com.android.packageinstaller:id/permission_allow_button').click()
sleep(1)
# 点击允许
dr.find_element(By.ID, 'com.android.packageinstaller:id/permission_allow_button').click()
sleep(1)
# 点击允许
dr.find_element(By.ID, 'com.android.packageinstaller:id/permission_allow_button').click()
sleep(1)

# 点击我的位置
dr.find_element(By.XPATH, '//android.widget.ImageView[@content-desc="我的位置"]').click()
sleep(1)
# 缩小
small(dr)
sleep(5)
# 放大
big(dr)
sleep(1)
dr.quit()



